<?php
namespace app\admin\validate;

use think\Validate;

class StockGoods extends Validate
{

    // 验证规则
    protected $rule = [
        'goods_name' => 'require|min:2|max:150|unique:stock_goods',
        'wid' => 'require|gt:0',
        'market_price' => 'require|float',
        'goods_price' => 'require|float|lt:market_price',
        'goods_img' => 'require',
        'store_count' => 'require|number',
        'sort' => 'require|number',
        'goods_content' => 'require',
    ];
    //错误信息
    protected $message = [
        'goods_name.require' => '商品名称必填',
        'goods_name.min' => '商品名称长度至少2个字符',
        'goods_name.max' => '商品名称长度至多150个字符',
        'goods_name.unique' => '商品名称重复',
        'wid.require' => '请选择可用钱包',
        'wid.gt' => '请选择可用钱包',
        'market_price.require' => '市场价格必填',
        'market_price.float' => '市场价格只能为数字',
        'goods_price.require' => '商品价格必填',
        'goods_price.float' => '商品价格只能为数字',
        'goods_price.lt' => '商品价格必须小于市场价格',
        'goods_img.require' => '商品主图必须上传',
        'store_count.require' => '商品库存必填',
        'store_count.number' => '商品库存只能为数字',
        'sort.require' => '商品排序必填',
        'sort.number' => '商品排序只能为数字',
        'goods_content.require' => '商品详情必填',
    ];
}
